/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package luft27.comm.mavlink;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;

/**
 *
 * @author amalikov
 */
public class GlobalPositionInt implements MessagePayload {
	public int time_boot_ms;
	public int lat;
	public int lon;
	public int alt;
	public int relative_alt;
	public short vx;
	public short vy;
	public short vz;
	public short hdg;
	
	@Override
	public byte[] get() {
		ByteBuffer bb = ByteBuffer.allocate(256).order(ByteOrder.LITTLE_ENDIAN);
		bb.putInt(time_boot_ms);
		bb.putInt(lat);
		bb.putInt(lon);
		bb.putInt(alt);
		bb.putInt(relative_alt);
		bb.putShort(vx);
		bb.putShort(vy);
		bb.putShort(vz);
		bb.putShort(hdg);		
		return Arrays.copyOf(bb.array(), bb.position());
	}

	@Override
	public void set(byte[] data) {
		ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);
		time_boot_ms = bb.getInt();
		lat = bb.getInt();
		lon = bb.getInt();
		alt = bb.getInt();
		relative_alt = bb.getInt();
		vx = bb.getShort();
		vy = bb.getShort();
		vz = bb.getShort();
		hdg = bb.getShort();
	}
}
